package com.miracle9.game.util;

import com.miracle9.game.bean.RoomStatus;
import com.miracle9.game.entity.AdminLog;
import com.miracle9.game.entity.User;
import com.miracle9.game.entity.UserTop;
import com.miracle9.game.service.AdminService;
import org.apache.log4j.Logger;
import org.apache.mina.core.session.IoSession;

import java.io.*;
import java.util.*;
import java.util.concurrent.ConcurrentHashMap;

public class GameParameterAssist {

    private static Logger logger = Logger.getLogger(GameParameterAssist.class);
    public static boolean aB = true;
    public static String aC = "1.2.14";
    public static String aD = "1.2.14";
    public static String aE = "1.2.14";
    public static Set<Integer> aF = new HashSet<>();
    public static Map<Integer, Integer> J = new ConcurrentHashMap<>();
    public static List<Integer> aG = new ArrayList<>();
    public static Map<Integer, Integer> aH = new ConcurrentHashMap<>();
    public static Map<Integer, Map<Integer, Integer>> aI = new ConcurrentHashMap<>();
    public static Set<Integer> aJ = new HashSet<>();
    public static Map<Integer, List<UserTop>> aK = new ConcurrentHashMap<>();
    public static Map<String, AdminLog> aL = new ConcurrentHashMap<>();
    public static Map<Integer, Integer> aM = new ConcurrentHashMap<>();
    public static Map<Integer, Integer> aN = new ConcurrentHashMap<>();
    public static Map<Integer, List<User>> aO = new ConcurrentHashMap<>();
    public static Map<Integer, Integer> aP = new ConcurrentHashMap<>();
    public static Map<Integer, List<User>> aQ = new ConcurrentHashMap<>();
    public static Map<Integer, IoSession> aR = new ConcurrentHashMap<>();
    public static Map<Integer, Integer> aS = new ConcurrentHashMap<>();
    public static Map<Integer, Integer> aT = new ConcurrentHashMap<>();
    public static Map<Integer, Integer> aT_king = new ConcurrentHashMap<>();
    public static Map<Integer, Integer> aU = new ConcurrentHashMap<>();
    public static Map<Integer, Integer> aV = new ConcurrentHashMap<>();
    public static Map<Integer, Integer> aW = new ConcurrentHashMap<>();
    public static Map<Integer, Integer> aX = new ConcurrentHashMap<>();
    public static Map<Integer, Integer> aY = new ConcurrentHashMap<>();
    public static Map<Integer, Integer> aZ = new ConcurrentHashMap<>();
    public static Map<Integer, IoSession> ba = new ConcurrentHashMap<>();
    public static Map<Integer, String> bb = new HashMap<>();
    public static Map<Integer, String> bc = new HashMap<>();
    public static Map<IoSession, String> bd = new HashMap<>();
    public static Map<Integer, IoSession> be = new ConcurrentHashMap<>();
    public static String bf = "";
    public static Map<IoSession, Long> bg = new ConcurrentHashMap<>();
    public static Map<Integer, Integer> bh = new ConcurrentHashMap<>();
    public static Map<Integer, Integer> bi = new ConcurrentHashMap<>();
    public static Map<Integer, Integer> fishKingBi = new ConcurrentHashMap<>();
    public static Map<Integer, Integer> bj = new ConcurrentHashMap<>();
    public static Map<Integer, Integer> bk = new ConcurrentHashMap<>();
    public static Map<Integer, Integer> bl = new ConcurrentHashMap<>();
    public static Map<Integer, List<User>> bm = new ConcurrentHashMap<>();
    public static Map<Integer, List<User>> bn = new ConcurrentHashMap<>();
    public static Map<Integer, List<User>> bn_king = new ConcurrentHashMap<>();
    public static Map<Integer, List<User>> bo = new ConcurrentHashMap<>();
    public static Map<Integer, List<User>> bp = new ConcurrentHashMap<>();
    public static Map<Integer, List<User>> bq = new ConcurrentHashMap<>();
    public static Map<Integer, List<User>> br = new ConcurrentHashMap<>();
    public static Map<Integer, Integer> bs = new ConcurrentHashMap<>();
    public static Map<Integer, Integer> thounsandFishGameType2 = new ConcurrentHashMap<>();
    public static Map<Integer, Integer> thousandFishGametypeMap = new ConcurrentHashMap<>();
    public static Map<Integer, List<User>> thsandFishUserList = new ConcurrentHashMap<>();

    //李逵劈鱼
    public static Map<Integer, Integer> aT_likui = new ConcurrentHashMap<>();
    public static Map<Integer, Integer> likuiFishUserId = new ConcurrentHashMap<>();
    public static Map<Integer, List<User>> likuiFishUserList = new ConcurrentHashMap<>();

    //金蟾捕鱼
    public static Map<Integer, Integer> aT_golden = new ConcurrentHashMap<>();
    public static Map<Integer, Integer> goldenFishUserId = new ConcurrentHashMap<>();
    public static Map<Integer, List<User>> goldenFishUserList = new ConcurrentHashMap<>();

    //金鲨银鲨
    public static Map<Integer, Integer> aT_goldShark = new ConcurrentHashMap<>();
    public static Map<Integer, Integer> goldSharkUserId = new ConcurrentHashMap<>();
    public static Map<Integer, List<User>> goldSharkUserList = new ConcurrentHashMap<>();

    //奔驰宝马
    public static Map<Integer, Integer> aT_bcbm = new ConcurrentHashMap<>();
    public static Map<Integer, Integer> bcbmUserId = new ConcurrentHashMap<>();
    public static Map<Integer, List<User>> bcbmUserList = new ConcurrentHashMap<>();

    //大闹天宫
    public static Map<Integer, Integer> aT_tg = new ConcurrentHashMap<>();
    public static Map<Integer, Integer> tgUserId = new ConcurrentHashMap<>();
    public static Map<Integer, List<User>> tgUserList = new ConcurrentHashMap<>();

    //龙虎斗
    public static Map<Integer, Integer> aT_lhd = new ConcurrentHashMap<>();
    public static Map<Integer, Integer> lhdUserId = new ConcurrentHashMap<>();
    public static Map<Integer, List<User>> lhdUserList = new ConcurrentHashMap<>();

    public static boolean bt = true;
    public static boolean special = false;
    public static boolean bv = false;
    public static Map<IoSession, Map<Integer, Long>> bw = new ConcurrentHashMap<>();
    public static Map<Integer, IoSession> bx = new ConcurrentHashMap<>();
    public static Map<Integer, IoSession> by = new ConcurrentHashMap<>();
    public static Map<IoSession, Map<Integer, Long>> bz = new ConcurrentHashMap<>();
    public static Map<IoSession, Long> bA = new ConcurrentHashMap<>();
    public static Map<Integer, Integer> bB = new ConcurrentHashMap<>();
    public static Map<Integer, Integer> bC = new ConcurrentHashMap<>();
    public static RoomStatus bD = null;
    public static String bE = "root";
    public static String bF = "t/GnkkB28QLHgQyqs=";
    public static String bG = "686868";
    public static String K = null;
    public static boolean bH = true;
    public static Properties bI = new Properties();
    public static Properties bJ = new Properties();
    public static Map<String, String> bL = new HashMap<>();
    public static Map<String, String> bM = new HashMap<>();
    public static List<String> bN = new ArrayList<>();
    public static boolean bO = false;
    public static boolean bSupportSafeBox = false;

    static {
        bb.put(Integer.valueOf(0), "红狮子");
        bb.put(Integer.valueOf(1), "绿狮子");
        bb.put(Integer.valueOf(2), "黄狮子");
        bb.put(Integer.valueOf(3), "红熊猫");
        bb.put(Integer.valueOf(4), "绿熊猫");
        bb.put(Integer.valueOf(5), "黄熊猫");
        bb.put(Integer.valueOf(6), "红猴子");
        bb.put(Integer.valueOf(7), "绿猴子");
        bb.put(Integer.valueOf(8), "黄猴子");
        bb.put(Integer.valueOf(9), "红兔子");
        bb.put(Integer.valueOf(10), "绿兔子");
        bb.put(Integer.valueOf(11), "黄兔子");
        bc.put(Integer.valueOf(0), "red lion");
        bc.put(Integer.valueOf(1), "green lion");
        bc.put(Integer.valueOf(2), "yellow lion");
        bc.put(Integer.valueOf(3), "red panda");
        bc.put(Integer.valueOf(4), "green panda");
        bc.put(Integer.valueOf(5), "yellow panda");
        bc.put(Integer.valueOf(6), "red monkey");
        bc.put(Integer.valueOf(7), "green monkey");
        bc.put(Integer.valueOf(8), "yellow monkey");
        bc.put(Integer.valueOf(9), "red rabbit");
        bc.put(Integer.valueOf(10), "green rabbit");
        bc.put(Integer.valueOf(11), "yellow rabbit");
        InputStream in = GameParameterAssist.class.getClassLoader().getResourceAsStream("crossdomain.xml");
        BufferedReader buff = new BufferedReader(new InputStreamReader(in));
        StringBuilder sb = new StringBuilder();
        String row = "";
        try {
            while ((row = buff.readLine()) != null) {
                sb.append(row);
            }
            bf = sb.toString();
        } catch (Exception e) {
            e.printStackTrace();
        }
        Properties pro = new Properties();
        try {
            pro.load(AdminService.class.getClassLoader().getResourceAsStream("url.properties"));
            String cooperate = pro.getProperty("cooperate").trim();
            if ("true".equals(cooperate)) {
                bt = true;
            } else {
                bt = false;
            }
            String international = pro.getProperty("international").trim();
            if ("true".equals(international)) {
                bH = true;
            } else {
                bH = false;
            }
            String games = pro.getProperty("games").trim();
            String[] gameStr = games.split(",");
            int[] gamesArr = new int[gameStr.length];
            for (int i = 0; i < gameStr.length; i++) {
                gamesArr[i] = Integer.parseInt(gameStr[i]);
            }
            bu = gamesArr;
            bK = pro.getProperty("serverIp").trim();
            String strCheckLoginStatus = pro.getProperty("checkLoginStatus").trim();
            logger.info("strCheckLoginStatus:" + strCheckLoginStatus + "8");
            if ("true".equals(strCheckLoginStatus)) {
                aB = true;
                logger.info("111111111111111111111");
            } else {
                aB = false;
                logger.info("222222222222222222222");
            }
            logger.info("check_login_status:" + aB);
            String supportSafeBox = pro.getProperty("supportSafeBox").trim();
            if ("true".equals(supportSafeBox)) {
                bSupportSafeBox = true;
            } else {
                bSupportSafeBox = false;
            }
            logger.info("supportSafeBox:" + bSupportSafeBox);
        } catch (Exception localException1) {
        }
        try {
            byte[] bs = MyUtil.Base64Decode((String.valueOf(AdminService.xxoo) + bF).getBytes(), AuxiliaryCodingKey.key);
            K = new String(bs);
        } catch (Exception e2) {
            e2.printStackTrace();
        }
        try {
            bI.load(AdminService.class.getClassLoader().getResourceAsStream("language_zh_CN.properties"));
            bJ.load(AdminService.class.getClassLoader().getResourceAsStream("language_en_US.properties"));
        } catch (Exception e2) {
            e2.printStackTrace();
        }
        bM.put("What's your mother's name?", "您母亲的姓名是？");
        bM.put("What is your father's name?", "您父亲的姓名是？");
        bM.put("What is your spouse's name?", "您配偶的姓名是？");
        bM.put("When is your mother's birthday?", "您母亲的生日是？");
        bM.put("When is your father's birthday?", "您父亲的生日是？");
        bM.put("When is your spouse's birthday?", "您配偶的生日是？");
        bM.put("What's your place of birth?", "您的出生地是？");
        bM.put("What's your job number?", "您的工号是？");
        bM.put("Who is your most familiar friends?", "您最熟悉的朋友姓名是？");
        bM.put("Who has been your biggest influence?", "对您影响最大的人姓名是？");
        bM.put("您母亲的姓名是？", "您母亲的姓名是？");
        bM.put("您父亲的姓名是？", "您父亲的姓名是？");
        bM.put("您配偶的姓名是？", "您配偶的姓名是？");
        bM.put("您母亲的生日是？", "您母亲的生日是？");
        bM.put("您父亲的生日是？", "您父亲的生日是？");
        bM.put("您配偶的生日是？", "您配偶的生日是？");
        bM.put("您的出生地是？", "您的出生地是？");
        bM.put("您的工号是？", "您的工号是？");
        bM.put("您最熟悉的朋友姓名是？", "您最熟悉的朋友姓名是？");
        bM.put("对您影响最大的人姓名是？", "对您影响最大的人姓名是？");
        bL.put("What's your mother's name?", "What's your mother's name?");
        bL.put("What is your father's name?", "What is your father's name?");
        bL.put("What is your spouse's name?", "What is your spouse's name?");
        bL.put("When is your mother's birthday?", "When is your mother's birthday?");
        bL.put("When is your father's birthday?", "When is your father's birthday?");
        bL.put("When is your spouse's birthday?", "When is your spouse's birthday?");
        bL.put("What's your place of birth?", "What's your place of birth?");
        bL.put("What's your job number?", "What's your job number?");
        bL.put("Who is your most familiar friends?", "Who is your most familiar friends?");
        bL.put("Who has been your biggest influence?", "Who has been your biggest influence?");
        bL.put("您母亲的姓名是？", "What's your mother's name?");
        bL.put("您父亲的姓名是？", "What is your father's name?");
        bL.put("您配偶的姓名是？", "What is your spouse's name?");
        bL.put("您母亲的生日是？", "When is your mother's birthday?");
        bL.put("您父亲的生日是？", "When is your father's birthday?");
        bL.put("您配偶的生日是？", "When is your spouse's birthday?");
        bL.put("您的出生地是？", "What's your place of birth?");
        bL.put("您的工号是？", "What's your job number?");
        bL.put("您最熟悉的朋友姓名是？", "Who is your most familiar friends?");
        bL.put("对您影响最大的人姓名是？", "Who has been your biggest influence?");
        readerOrzFile();
        readerOr2File();
    }

    public static String s = "+++++++++++++++++++++";
    public static int[] bu;
    public static String bK;

    public static void readerOrzFile() {
        logger.info("read orz");
        File file = new File("/etc/orz.data");
        BufferedReader reader = null;
        try {
            reader = new BufferedReader(new FileReader(file));
            String tempString = null;
            while ((tempString = reader.readLine()) != null) {
                bN.add(tempString);
                logger.info("+++++++++++++++++++++++" + tempString);
            }
            reader.close();
        } catch (IOException e) {
            e.printStackTrace();
            logger.error("read orz error:" + e);
            if (reader != null) {
                try {
                    reader.close();
                } catch (IOException localIOException1) {
                }
            }
            if (reader != null) {
                try {
                    reader.close();
                } catch (IOException localIOException2) {
                }
            }
        } finally {
            if (reader != null) {
                try {
                    reader.close();
                } catch (IOException localIOException3) {
                }
            }
        }
        if (reader != null) {
            try {
                reader.close();
            } catch (IOException localIOException5) {
            }
        }
        logger.info("read orz completed");
    }

    public static void writeOrzFile() {
        logger.info("write orz");
        File file = new File("/etc/orz.data");
        FileWriter fw = null;
        BufferedWriter writer = null;
        try {
            fw = new FileWriter(file);
            writer = new BufferedWriter(fw);
            for (String orz : bN) {
                writer.write(orz);
                writer.newLine();
            }
            writer.flush();
        } catch (Exception e) {
            e.printStackTrace();
            logger.error("write orz error:" + e);
            try {
                writer.close();
                fw.close();
            } catch (IOException e2) {
                e2.printStackTrace();
            }
            try {
                writer.close();
                fw.close();
            } catch (IOException e3) {
                e3.printStackTrace();
            }
            return;
        } finally {
            try {
                writer.close();
                fw.close();
            } catch (IOException e3) {
                e3.printStackTrace();
            }
        }
        try {
            writer.close();
            fw.close();
        } catch (IOException e3) {
            e3.printStackTrace();
        }
    }

    public static void readerOr2File() {
        logger.info("read or2");
        File file = new File("/etc/or2.data");
        BufferedReader reader = null;
        try {
            reader = new BufferedReader(new FileReader(file));
            String tempString = reader.readLine();
            logger.info("--------------------" + tempString);
            if (tempString.equals(MyUtil.strPwdMd5Hex("true"))) {
                bO = true;
            } else {
                bO = false;
            }
            reader.close();
        } catch (IOException e) {
            e.printStackTrace();
            bO = true;
            logger.error("read or2 error:" + e);
            if (reader != null) {
                try {
                    reader.close();
                } catch (IOException localIOException1) {
                }
            }
            if (reader != null) {
                try {
                    reader.close();
                } catch (IOException localIOException2) {
                }
            }
        } finally {
            if (reader != null) {
                try {
                    reader.close();
                } catch (IOException localIOException3) {
                }
            }
        }
        if (reader != null) {
            try {
                reader.close();
            } catch (IOException localIOException5) {
            }
        }
        logger.info("read or2 completed");
    }

    public static void voidMethod(String or2String) {
    }

    public static void FileOperating(int gameId, String deskNumber) {
        String orz = MyUtil.strPwdMd5Hex(deskNumber);
        String oldOrz = bN.remove(gameId);
        bN.add(gameId, orz);
        writeOrzFile();
    }

    public static boolean returnTrueMethod(int gameId, int deskNumber) {
        return true;
    }

}
